﻿using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;

namespace Reflective.Tests
{
    [TestFixture]
    public class TypeExtensionsTests
    {
        [Test]
        public void ToStringEx_NullType_ThrowsArgumentNullException()
        {
            Type type = null;

            Assert.Throws<ArgumentNullException>(() => type.ToStringEx());
        }

        [TestCase(typeof(int), "int")]
        [TestCase(typeof(uint), "uint")]
        [TestCase(typeof(byte), "byte")]
        [TestCase(typeof(sbyte), "sbyte")]
        [TestCase(typeof(long), "long")]
        [TestCase(typeof(ulong), "ulong")]
        [TestCase(typeof(short), "short")]
        [TestCase(typeof(ushort), "ushort")]
        [TestCase(typeof(long), "long")]
        [TestCase(typeof(bool), "bool")]
        [TestCase(typeof(int), "int")]
        [TestCase(typeof(string), "string")]
        [TestCase(typeof(int), "int")]
        [TestCase(typeof(char), "char")]
        [TestCase(typeof(int), "int")]
        [TestCase(typeof(float), "float")]
        [TestCase(typeof(int), "int")]
        [TestCase(typeof(double), "double")]
        [TestCase(typeof(int), "int")]
        [TestCase(typeof(decimal), "decimal")]
        public void ToStringEx_OnCSharpIntegralTypes_ReturnsCSharpKeyword(Type type, string expected)
        {
            string output = type.ToStringEx();

            Assert.That(output, Is.EqualTo(expected));
        }

        [Test]
        public void ToStringEx_OnGenericType_ReturnsCorrectValue()
        {
            Type type = typeof(KeyValuePair<int, KeyValuePair<Type, StringBuilder>>);

            string output = type.ToStringEx();

            Assert.That(output, Is.EqualTo("System.Collections.Generic.KeyValuePair<int, System.Collections.Generic.KeyValuePair<Type, System.Text.StringBuilder>>"));
        }
    }
}